package com.xdwanj.criminalintent.dao;

import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.RoomDatabase;
import androidx.room.TypeConverters;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

import com.xdwanj.criminalintent.pojo.Crime;
import com.xdwanj.criminalintent.pojo.TypeConverters.CrimeTypeConverters;

@Database(entities = {Crime.class}, version = 2, exportSchema = false)
@TypeConverters({CrimeTypeConverters.class})
public abstract class CrimeDatabase extends RoomDatabase {

    public abstract CrimeDao crimeDao();

    public static final Migration MIGRATION_1_2 = new Migration(1, 2) {
        @Override
        public void migrate(@NonNull SupportSQLiteDatabase database) {
            database.execSQL(" ALTER TABLE Crime ADD COLUMN suspect TEXT NOT NULL DEFAULT '' ");
        }
    };
}
